{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "17244855",
   "metadata": {},
   "source": [
    "* 记录人：Lz  \n",
    "* 时间：2021-12-06  \n",
    "* week15: 函数与模块进阶    \n",
    "* 线上学习资源：  \n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e0d3a50b",
   "metadata": {},
   "source": [
    "## 上周回顾  \n",
    "> 1.函数的定义：def  \n",
    "> 2.函数名的定义规则->变量名一样的规则\n",
    "> 3.调用函数的方式\n",
    "> 4.参数：\n",
    ">> A 形式参数（定义函数）\n",
    ">> B 实际参数（调用函数）\n",
    ">> C 有多个参数时：\n",
    ">>> a.关键字参数\n",
    ">>> b.位置参数（调用函数时） ——> 关键字参数均要放在末尾（多个不考虑顺序）  \n",
    ">>> c.默认参数（定义函数时） ——> 默认参数均要放在末尾（多个不考虑顺序）  \n",
    "\n",
    "## 本周知识\n",
    "> 1.函数的返回值  \n",
    "> 2.函数的参数类型  \n",
    "> 3.模块与函数的关系  \n",
    "> 4.定义一个模块，然后调用模块  \n",
    ">> A 调用模块  \n",
    ">> B 调用模块中的函数\n",
    "\n",
    "> 5.模块与函数实践  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68f45986",
   "metadata": {},
   "source": [
    "### 1. 函数的返回值  \n",
    "* 1.函数一定有返回值（无论什么编程语言）\n",
    "* 2.在其他的编程语言中（如c语言，java等），返回值一定要写，不写会报错；对于python，返回值如果不写，则返回给定的默认值None\n",
    "* 3.返回值一般为函数体运行的结果（result）；也可以是自定义的函数返回值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "3533258f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 函数返回实践1（函数体的运行结果）\n",
    "def get_formatted_name(first_name,last_name):\n",
    "        \"\"\"返回整洁的姓名\"\"\"\n",
    "        full_name = first_name + \" \" + last_name\n",
    "      #  print(full_name)\n",
    "        return full_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9c4b1abf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "li hua\n"
     ]
    }
   ],
   "source": [
    "get_formatted_name(\"li\",\"hua\")   # --> print打印的结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "27b10750",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'li hua'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_formatted_name(\"li\",\"hua\")  # --> return 返回的结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "f9a2c8ae",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 函数返回值是自定义的\n",
    "def log_in(username,password):\n",
    "    \"\"\"验证登录信息\"\"\"\n",
    "    if username == \"lihua\" and password == 123456:\n",
    "        return 1\n",
    "    else:\n",
    "        return 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "f9b9390a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log_in(\"lihua\",123456)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7743f078",
   "metadata": {},
   "source": [
    "### 2.函数的参数类型  \n",
    "* 1.函数输入的参数  \n",
    "> 1.函数参数为列表    \n",
    "> 2.函数参数为字典  \n",
    "---\n",
    "* 2. 函数可以输入不确定个数的参数：  \n",
    "> A * args  \n",
    "> B ** kwargs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "46a4969f",
   "metadata": {},
   "outputs": [],
   "source": [
    "def list_test(names):\n",
    "    \"\"\"测试输入参数为列表\"\"\"\n",
    "    print(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "f03cfd9e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['lihua', 'xiaoming', 'xiaoho']\n"
     ]
    }
   ],
   "source": [
    "list_test([\"lihua\",\"xiaoming\",\"xiaoho\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "a005bbe7",
   "metadata": {},
   "outputs": [],
   "source": [
    "def dict_test(request_header):\n",
    "    \"\"\"测试输入参数为字典\"\"\"\n",
    "    print(request_header)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "26257fb7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 来源于http://httpbin.org/get\n",
    "httpbin_get = {\n",
    "     \"args\": {}, \n",
    "  \"headers\": {\n",
    "    \"Accept\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\", \n",
    "    \"Accept-Encoding\": \"gzip, deflate\", \n",
    "    \"Accept-Language\": \"zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6\", \n",
    "    \"Host\": \"httpbin.org\", \n",
    "    \"Upgrade-Insecure-Requests\": \"1\", \n",
    "    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 Edg/96.0.1054.43\", \n",
    "    \"X-Amzn-Trace-Id\": \"Root=1-61adb9d7-57ea7d3a6703dd551e1d3bb4\"\n",
    "  }, \n",
    "  \"origin\": \"117.136.41.83\", \n",
    "  \"url\": \"http://httpbin.org/get\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "70a4f443",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6', 'Host': 'httpbin.org', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 Edg/96.0.1054.43', 'X-Amzn-Trace-Id': 'Root=1-61adb9d7-57ea7d3a6703dd551e1d3bb4'}\n"
     ]
    }
   ],
   "source": [
    "dict_test(httpbin_get['headers'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4759f193",
   "metadata": {},
   "source": [
    "* 2. 函数可以输入不确定个数的参数：  \n",
    "> A * args \n",
    ">> 1. args 可以接受多个数据（单值）  \n",
    ">> 2.args将多个数据存在一个**元组**当中，实际还是一个变量   \n",
    "\n",
    "> B ** kwargs  \n",
    ">> 1.kwargs 可以接受多个数据(键值对)==> 关键字参数  \n",
    ">> 2.kwargs 将多个 键值对 的数据存放在一个**字典**中，实际上还是一个变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "a57322a9",
   "metadata": {},
   "outputs": [],
   "source": [
    "#  *args\n",
    "def food_ingred(food,*ingreds):\n",
    "    \"\"\"食物配料单\"\"\"\n",
    "    return food,ingreds"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "b4c11270",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('pizza', ('mushroom', 'green pepers', 'extra cheese'))"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "food_ingred(\"pizza\",\"mushroom\",\"green pepers\",\"extra cheese\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "b59ce77f",
   "metadata": {},
   "outputs": [],
   "source": [
    "#  **kwargs\n",
    "def person(stud_name,**stud_info):\n",
    "    \"\"\"学生个人信息完善表\"\"\"\n",
    "    return stud_name,stud_info  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "8c3091ef",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('Lihua', {'age': 18, 'job': 'student', 'address': '广州南方学院'})"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "person(\"Lihua\",age=18,job=\"student\",address=\"广州南方学院\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "74688eae",
   "metadata": {},
   "outputs": [],
   "source": [
    "def func_name(arg1,arg2,*arg,**kwargs):\n",
    "    \"\"\"考虑比较周到的函数\"\"\"\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "559c52e0",
   "metadata": {},
   "source": [
    "### 2.函数输出的返回值  \n",
    "* 1.返回值可以是 字符串、数值、列表、字典等数据（单一值）  \n",
    "* 2.返回值是唯一的，不可以有两个  \n",
    "* 3.python 可以输出多个返回值。结果会用一个元组进行封装并返回（本质不违背函数的定义） \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "9dc9e365",
   "metadata": {},
   "outputs": [],
   "source": [
    "def test1_return():\n",
    "    \"\"\"测试返回值\"\"\"\n",
    "    return \"hello\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "5732b74a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hello'"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test1_return()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "47b83e5d",
   "metadata": {},
   "outputs": [],
   "source": [
    "def test2_return():\n",
    "    \"\"\"测试返回值\"\"\"\n",
    "    return [1,2,3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "f9564e2b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test2_return()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "281ebc85",
   "metadata": {},
   "outputs": [],
   "source": [
    "def test3_return():\n",
    "    \"\"\"测试返回值\"\"\"\n",
    "    return {\"01\":\"cc\",\"02\":\"dd\",\"03\":\"hh\"}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "28ca3319",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'01': 'cc', '02': 'dd', '03': 'hh'}"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test3_return()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "e41859cd",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 测试返回多个值\n",
    "\n",
    "def test5_return():\n",
    "    \"\"\"测试返回值return\"\"\"\n",
    "    return 1,2,\"cc\",[0,1,2,3,4,5],{\"cc\":\"30\"}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "4faf12b3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1, 2, 'cc', [0, 1, 2, 3, 4, 5], {'cc': '30'})"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test5_return()      # 返回多个值的时候，return会把多个值用元组进行封装再返回"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "992df67c",
   "metadata": {},
   "source": [
    "### 3.模块  \n",
    "* 1.使用模块可以隐藏函数的源代码    \n",
    "* 2.使用的人不需要会底层代码（只需要会使用模块即可） \n",
    "---\n",
    "* 3.调用模块的方法 \n",
    "> 1.必须先调用模块，才可以使用\n",
    ">> 1. import moudle_name 直接调用整个模块，此时模块的所有函数处于备用状态，使用的方法为：moudle_name.func_name()  \n",
    ">> 2. from moudle_name import func_name,此时，仅调用模块的某一个函数，只能使用这个模块的该函数，使用方法为 func_name()  \n",
    "\n",
    "> 2.创建模块  \n",
    "**注意一定要使你所创建的模块函数文件（study.py）和你将要调用该模块中的函数的代码文件在同一级文件路径下**例如把secher4vowels.py和study.py 放在同一个文件夹里并且两者是同级关系。否则无法调用你所创建的模块。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4576145f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import study"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "cf883d9f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'e', 'o'}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "study.search4vowels(\"hello word\")    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "58e428b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=12, tm_mday=6, tm_hour=16, tm_min=43, tm_sec=15, tm_wday=0, tm_yday=340, tm_isdst=0)"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 调用整个模块\n",
    "import time\n",
    "time.localtime()    # 该种方法调用模块中的某个函数比较耗损内存，因为这是从一个模块下的所有的函数中查找所需的那个特指函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6d494207",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 调用模块中某一个函数\n",
    "from study import search4vowels     # 使用 from   import 会更加快以及不易耗损内存来调用函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a6809b5d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'a', 'e', 'i', 'o'}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "search4vowels(\"i think it hard to learn by python\")    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9f8738a3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function news_链接 in module study:\n",
      "\n",
      "news_链接(url, 新闻分类, page)\n",
      "    抓取学校新闻的所有页面链接\n",
      "    url:学校网站的域名链接\n",
      "    新闻分类:学校新闻的分类英文简称\n",
      "    page:你想要抓取的页面尾页\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(study.news_链接)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c825ddf8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['https://www.nfu.edu.cn/xydt/index.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index1.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index2.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index3.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index4.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index5.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index6.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index7.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index8.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index9.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index10.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index11.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index12.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index13.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index14.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index15.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index16.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index17.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index18.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index19.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index20.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index21.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index22.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index23.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index24.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index25.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index26.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index27.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index28.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index29.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index30.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index31.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index32.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index33.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index34.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index35.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index36.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index37.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index38.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index39.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index40.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index41.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index42.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index43.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index44.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index45.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index46.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index47.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index48.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index49.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index50.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index51.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index52.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index53.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index54.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index55.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index56.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index57.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index58.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index59.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index60.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index61.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index62.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index63.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index64.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index65.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index66.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index67.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index68.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index69.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index70.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index71.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index72.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index73.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index74.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index75.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index76.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index77.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index78.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index79.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index80.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index81.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index82.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index83.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index84.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index85.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index86.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index87.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index88.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index89.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index90.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index91.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index92.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index93.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index94.htm',\n",
       " 'https://www.nfu.edu.cn/xydt/index95.htm']"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "study.news_链接('https://www.nfu.edu.cn/','xydt','96')  # 广州南方学院官网，学校动态，96页"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "67f88e90",
   "metadata": {},
   "source": [
    "#### 使用as 给函数指定别名  \n",
    "* 我们可以指定函数的另一个名称，类似于外号。 这样可以简化函数名  \n",
    "* 通用语法格式： from moudle_name import function_name as fn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "99bdd8b4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'a', 'e', 'u'}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from study import search4vowels as sv\n",
    "sv(\"study better day by day\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "852888ef",
   "metadata": {},
   "source": [
    "#### 使用as给模块指定别名  \n",
    "* 通用语法： import moudle_name as mn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "2000d910",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'a', 'e', 'u'}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import study as s\n",
    "s.search4vowels(\"hdwhddhywbegduyas\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ef2bce62",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
